#include <iostream>
#include <stack>
#include <unordered_map>
#include <string>

bool isValidSequence(std::string s) {
    std::stack<char> stack;
    std::unordered_map<char, char> brackets = {{'(', ')'}, {'[', ']'}, {'{', '}'}, {'<', '>'}};
    
    for (char c : s) {
        if (brackets.find(c) != brackets.end()) {
            stack.push(c);
        } else if (!stack.empty() && brackets[stack.top()] == c) {
            stack.pop();
        } else {
            return false;
        }
    }
    
    return stack.empty();
}

int main() {
    std::string sequence;
    std::cout << "Введите последовательность скобок: ";
    std::cin >> sequence;
    
    std::cout << (isValidSequence(sequence) ? "true" : "false") << std::endl;
    
    return 0;
}